﻿/* PC INpact App for Chrome™

	PC INpact App for Chrome™ est une application destinée au Chrome Web Store permettant d'acchéder à PC INpact.
	Elle dispose de fonctionnalités spécifiques, telles que la notification de nouvelles actualités, dossiers...

	Main author : LEGRAND David
	Mail : david@pcinpact.com
	
	Google Code Project : http://pci.im/code-pci-chrome 
	Forum : http://pci.im/forum-pci-chrome
	
    This file is part of PC INpact App for Chrome™.

    PC INpact App for Chrome™ is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    PC INpact App for Chrome™ is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with PC INpact App for Chrome™.  If not, see <http://www.gnu.org/licenses/>. 

    You're not allowed to use PC INpact App for Chrome™ name or logo without permission */
 
 //Une fonction qui gère les notifications via TXT
function notify_txt(icon, title, body) 
{
	// Si l'utilisateur a demandé à ne pas avoir de notifications, on part
	if (localStorage["notif_ckeck"] != 1)
		return;

	// On affiche la notification
	var notification = webkitNotifications.createNotification(icon, title, body);
	notification.show();

	// On attend le temps indiqué avant de fermer la notification
	setTimeout(function() {
		notification.cancel();
	}, localStorage["notif_delay"] * 1000);
}

//Une fonction qui gère les notifications via URL
function notify_url(url) 
{
	// Si l'utilisateur a demandé à ne pas avoir de notifications, on part
	if (localStorage["notif_ckeck"] != 1)
		return;

	
	// On affiche la notification
	var notification = webkitNotifications.createHTMLNotification(url);
	notification.show();

	// On attend le temps indiqué avant de fermer la notification
	setTimeout(function() {
		notification.cancel();
	}, localStorage["notif_delay"] * 1000);
}